import { View,Image } from "@tarojs/components";

import failIcon from '@/assets/images/warn.png'
import { forwardRef, useEffect } from "react";
import JoinNoticeDialog from '@/components/joinNoticeDialog/joinNoticeDialog'
import useProfileInfoAction from "@/hooks/useProfileInfoAction";
import { handleCleanStore, handleGoKnow, toPage } from "@/common/util";
import {  PAGE_TYPE } from "@/common/config";
// import { useStore } from "@/store";



interface IJoinFailDialog {
    profileRemark: string
    noticeShow:boolean
    handlePopStatus: (status) => void;

}

const JoinFailDialog: React.FC<IJoinFailDialog> = forwardRef(({ profileRemark,noticeShow,handlePopStatus }, ref) => {
    // const { jobStore} = useStore()
    let pageTimeOut;
    const { handleInitStoreProfileInfo } = useProfileInfoAction();
    const handlePopStatusAction = (popStatus) => {
        handlePopStatus(popStatus)
    }
    const handleGoEdit = async () => {
        handleCleanStore();
        // regionStore.handleInitRegionList()
        // jobStore.handleInitJobList();
        // serviceStore.handleInitServiceTypeList()
        handlePopStatus(false);
         handleInitStoreProfileInfo();
         pageTimeOut= setTimeout(() => {
            toPage(PAGE_TYPE.USER_JOIN_INFO)
          }, 300);
    }
    useEffect(() => {
        
        return () => {
            if (pageTimeOut) {
                clearTimeout(pageTimeOut);
            }
        };
    }, []);
   
    return (
        <>
            <View className="h-100vh flex items-center justify-center flex-col">
                <View className="relative flex flex-col items-center">
                    <Image src={failIcon} className="w-122px h-122px relative z-2"></Image>
                    <View className="w-650px bg-#fff pt-118px pb-52px box-border -mt-50px">

                        <View className="pl-46px pr-34px text-#333 font-medium text-32px leading-50px">入驻信息审核不通过，请按提示修改后重新提交。</View>
                        <View className="pl-46px pr-48px text-#666666 text-28px leading-56px mt-18px">{profileRemark}
                        </View>
                        <View className="w-556px h-92px bg-#8232E8 flex items-center justify-center text-#fff text-28px font-medium mt-32px mx-auto" onClick={() => handlePopStatus(true)}>修改信息</View>
                    </View>
                    <View className="mt-50px w-full mx-auto text-center text-#242424 text-29px" onClick={handleGoKnow}>了解如何推广及接单 》</View>
                </View>
            </View>
            <JoinNoticeDialog noticeShow={noticeShow} handlePopStatus={handlePopStatusAction} handleGoAction={handleGoEdit}></JoinNoticeDialog>
        </>
    )
})

export default JoinFailDialog